package fly.config;

import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authc.AuthenticationInfo;
import org.apache.shiro.authc.AuthenticationToken;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.authc.credential.SimpleCredentialsMatcher;

import java.util.Arrays;

/**
 * 凭证匹配器
 */
public class MyCredentialsMatcher extends SimpleCredentialsMatcher {
    //证书匹配
    @Override
    public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
        UsernamePasswordToken usernamePasswordToken = (UsernamePasswordToken) token;
        String password = new String(usernamePasswordToken.getPassword());
        // 获取凭证
        String dbPassword = (String) info.getCredentials();
        System.out.println("【password】" + password);
        System.out.println("【dbPassword】" + dbPassword);
        boolean equals = this.equals(password, dbPassword);
        System.out.println("【密码一致】"+equals);
        return equals;
    }
}
